package leetcode.code036;

public class Solution extends Solution036 {

	@Override
	public boolean isValidSudoku(char[][] board) {
		final int len = 9;
		boolean[][] check = new boolean[len * 3][len + 1];
		for (int i = 0; i < len; i++) {
			for (int j = 0; j < len; j++) {
				char c = board[i][j];
				if (c == '.')
					continue;
				int ic = c - '0';
				int x1 = i;
				if (!check[x1][ic])
					check[x1][ic] = true;
				else
					return false;
				int x2 = j + len;
				if (!check[x2][ic])
					check[x2][ic] = true;
				else
					return false;
				int x3 = (i / 3) * 3 + (j / 3) + 18;
				if (!check[x3][ic])
					check[x3][ic] = true;
				else
					return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();

	}

}
